<?php

use yii\helpers\Html;
use kartik\widgets\ActiveForm;
use kartik\widgets\TouchSpin;

/* @var $this yii\web\View */
/* @var $model common\models\DictionaryType */
/* @var $form yii\widgets\ActiveForm */

\mootensai\components\JsBlock::widget(['viewFile' => '_script', 'pos'=> \yii\web\View::POS_END,
    'viewParams' => [
        'class' => 'Dictionary',
        'relID' => 'dictionary',
        'value' => \yii\helpers\Json::encode($model->dictionaries),
        'isNewRecord' => ($model->isNewRecord) ? 1 : 0
    ]
]);
?>

<div class="dictionary-type-form">

    <?php $form = ActiveForm::begin([
        'type' => ActiveForm::TYPE_INLINE,
         'formConfig' => ['showHints' => false, 'autoPlaceholder'=>true],
    ]); ?>

    <?= $form->errorSummary($model); ?>

        <?= $form->field($model, 'name',[
            'showLabels'=>true
        ])->textInput(); ?>

        <?= $form->field($model, 'code',[
            'showLabels'=>true
        ])->textInput(); ?>

        <?= $form->field($model, 'order_num',[
            'showLabels'=>true
        ])->widget(TouchSpin::className(), [
            'options'=>['placeholder'=>'order_num'],
            'pluginOptions' => [
                'buttonup_class' => 'btn btn-success',
                'buttondown_class' => 'btn btn-success',
                'step' => 1.0,
            ]
        ]); ?>

        <?= $form->field($model, 'customizable')->checkbox() ?>
    <?php
    $forms = [
        [
            'label' => '<i class="glyphicon glyphicon-book"></i> ' . Html::encode('字典'),
            'content' => $this->render('_formDictionary', [
                'row' => \yii\helpers\ArrayHelper::toArray($model->dictionaries),
            ]),
        ],
    ];
    echo kartik\tabs\TabsX::widget([
        'items' => $forms,
        'position' => kartik\tabs\TabsX::POS_ABOVE,
        'encodeLabels' => false,
        'pluginOptions' => [
            'bordered' => true,
            'sideways' => true,
            'enableCache' => false,
        ],
    ]);
    ?>
    <div class="form-group">
        <?= Html::submitButton($model->isNewRecord ? '添加' : '保存', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
        <?= Html::a(Yii::t('app', '取消'), Yii::$app->request->referrer , ['class'=> 'btn btn-danger']) ?>
    </div>

    <?php ActiveForm::end(); ?>

</div>
